﻿using ReflectionStudio.Core.Events;
using System;
using System.Data;
namespace WPFExcelReport
{
    public partial class ITXEXRPT
    {

        public void YGRXJSH(DataSet db)
        {
            try
            {
                //长度			注意：客户名称必须和intex的客户名称一致			注意，成分名称必须和intex内的一致																					

                DataTable dtSoruce = db.Tables["VAKDBEZ"];
                DataTable dtOutput = new DataTable();
                int idx = 1;
                int x = 2;
                double value = 0;
                exAgent.SetCellValue(x, idx++, "ROWID");
                exAgent.SetCellValue(x, idx++, "ITXHAVE");
                exAgent.SetCellValue(x, idx++, "VAKBKUNDNR");
                exAgent.SetCellValue(x, idx++, "KDKUNDNA");
                exAgent.SetCellValue(x, idx++, "VAKBKOLL");
                exAgent.SetCellValue(x, idx++, "VAKBFARBE");
                exAgent.SetCellValue(x, idx++, "VAFBEZ");
                exAgent.SetCellValue(x, idx++, "VAKBKDFARBNR");
                exAgent.SetCellValue(x, idx++, "VAKBKDARTBEZ");
                exAgent.SetCellValue(x, idx++, "CR");
                exAgent.SetCellValue(x, idx++, "CG");
                exAgent.SetCellValue(x, idx++, "CB");
                exAgent.SetCellValue(x, idx++, "CGRP");
                exAgent.SetCellValue(x, idx++, "VAAGESANT1");
                exAgent.SetCellValue(x, idx++, "VAAGESBEZ1");
                exAgent.SetCellValue(x, idx++, "VAAGESANT2");
                exAgent.SetCellValue(x, idx++, "VAAGESBEZ2");
                exAgent.SetCellValue(x, idx++, "VAAGESANT3");
                exAgent.SetCellValue(x, idx++, "VAAGESBEZ3");
                exAgent.SetCellValue(x, idx++, "VAAGESANT4");
                exAgent.SetCellValue(x, idx++, "VAAGESBEZ4");
                exAgent.SetCellValue(x, idx++, "VAAGESANT5");
                exAgent.SetCellValue(x, idx++, "VAAGESBEZ5");
                exAgent.SetCellValue(x, idx++, "VAAGESANT6");
                exAgent.SetCellValue(x, idx++, "VAAGESBEZ6");
                exAgent.SetCellValue(x, idx++, "VAAGESANT7");
                exAgent.SetCellValue(x, idx++, "VAAGESBEZ7");
                exAgent.SetCellValue(x, idx++, "VAAGESANT8");
                exAgent.SetCellValue(x, idx++, "VAAGESBEZ8");
                idx = 1;
                exAgent.SetCellValue(x - 1, idx++, "ROWID0"); dtOutput.Columns.Add("ROWNID", typeof(System.String));
                exAgent.SetCellValue(x - 1, idx++, "标志-1"); dtOutput.Columns.Add("ITXHAVE", typeof(System.String));
                exAgent.SetCellValue(x - 1, idx++, "客户编号-8"); dtOutput.Columns.Add("VAKBKUNDNR", typeof(System.String));
                exAgent.SetCellValue(x - 1, idx++, "客户-8"); dtOutput.Columns.Add("KDKUNDNA", typeof(System.String));
                exAgent.SetCellValue(x - 1, idx++, "季节-5"); dtOutput.Columns.Add("VAKBKOLL", typeof(System.String));
                exAgent.SetCellValue(x - 1, idx++, "色号-10"); dtOutput.Columns.Add("VAKBFARBE", typeof(System.String));
                exAgent.SetCellValue(x - 1, idx++, "色名-20"); dtOutput.Columns.Add("VAFBEZ", typeof(System.String));
                exAgent.SetCellValue(x - 1, idx++, "客户色号-29"); dtOutput.Columns.Add("VAKBKDFARBNR", typeof(System.String));
                exAgent.SetCellValue(x - 1, idx++, "客户色名-29"); dtOutput.Columns.Add("VAKBKDARTBEZ", typeof(System.String));
                exAgent.SetCellValue(x - 1, idx++, "R-3"); dtOutput.Columns.Add("CR", typeof(System.String));
                exAgent.SetCellValue(x - 1, idx++, "G-3"); dtOutput.Columns.Add("CG", typeof(System.String));
                exAgent.SetCellValue(x - 1, idx++, "B-3"); dtOutput.Columns.Add("CB", typeof(System.String));
                exAgent.SetCellValue(x - 1, idx++, "组-1"); dtOutput.Columns.Add("CGRP", typeof(System.String));
                exAgent.SetCellValue(x - 1, idx++, "比例1-0"); dtOutput.Columns.Add("VAAGESANT1", typeof(System.String));
                exAgent.SetCellValue(x - 1, idx++, "成份1-3"); dtOutput.Columns.Add("VAAGESBEZ1", typeof(System.String));
                exAgent.SetCellValue(x - 1, idx++, "比例2-0"); dtOutput.Columns.Add("VAAGESANT2", typeof(System.String));
                exAgent.SetCellValue(x - 1, idx++, "成份2-3"); dtOutput.Columns.Add("VAAGESBEZ2", typeof(System.String));
                exAgent.SetCellValue(x - 1, idx++, "比例3-0"); dtOutput.Columns.Add("VAAGESANT3", typeof(System.String));
                exAgent.SetCellValue(x - 1, idx++, "成份3-3"); dtOutput.Columns.Add("VAAGESBEZ3", typeof(System.String));
                exAgent.SetCellValue(x - 1, idx++, "比例4-0"); dtOutput.Columns.Add("VAAGESANT4", typeof(System.String));
                exAgent.SetCellValue(x - 1, idx++, "成份4-3"); dtOutput.Columns.Add("VAAGESBEZ4", typeof(System.String));
                exAgent.SetCellValue(x - 1, idx++, "比例5-0"); dtOutput.Columns.Add("VAAGESANT5", typeof(System.String));
                exAgent.SetCellValue(x - 1, idx++, "成份5-3"); dtOutput.Columns.Add("VAAGESBEZ5", typeof(System.String));
                exAgent.SetCellValue(x - 1, idx++, "比例6-0"); dtOutput.Columns.Add("VAAGESANT6", typeof(System.String));
                exAgent.SetCellValue(x - 1, idx++, "成份6-3"); dtOutput.Columns.Add("VAAGESBEZ6", typeof(System.String));
                exAgent.SetCellValue(x - 1, idx++, "比例7-0"); dtOutput.Columns.Add("VAAGESANT7", typeof(System.String));
                exAgent.SetCellValue(x - 1, idx++, "成份7-3"); dtOutput.Columns.Add("VAAGESBEZ7", typeof(System.String));
                exAgent.SetCellValue(x - 1, idx++, "比例8-0"); dtOutput.Columns.Add("VAAGESANT8", typeof(System.String));
                exAgent.SetCellValue(x - 1, idx++, "成份8-3"); dtOutput.Columns.Add("VAAGESBEZ8", typeof(System.String));
                dtOutput.Merge(dtSoruce, false, MissingSchemaAction.Ignore);
                foreach (DataRow rx in dtOutput.Rows)
                {
                    rx["KDKUNDNA"] = GetGB2312Value(rx["KDKUNDNA"].ToString().Trim());
                    rx["VAFBEZ"] = GetGB2312Value(rx["VAFBEZ"].ToString().Trim());
                    rx["VAKBKOLL"] = GetGB2312Value(rx["VAKBKOLL"].ToString().Trim());
                    rx["VAKBKDFARBNR"] = GetGB2312Value(rx["VAKBKDFARBNR"].ToString().Trim());
                    rx["VAKBKDARTBEZ"] = GetGB2312Value(rx["VAKBKDARTBEZ"].ToString().Trim());
                }
                exAgent.DataTableToExcel(dtOutput, x + 1, 1);

            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            finally
            {
                EventDispatcher.Instance.RaiseStatus("完成", StatusEventType.StopProgress);
            }
        }

    }
}